<?php
class AnswerControl extends Control{
	public function index(){
		//所有答案 ******************************************
			$allanswer = "SELECT *FROM hd_answer";
			$allanswer = M('wenda')->query($allanswer);
			// var_dump($allask);
			$this->assign('allanswer',$allanswer);
		
		$this->display('answer.html');
	}
	public function answer_1(){
		//未采纳的答案 ******************************************
			$allanswer = "SELECT *FROM hd_answer WHERE accept=0";
			$allanswer = M('wenda')->query($allanswer);
			// var_dump($allask);
			$this->assign('allanswer',$allanswer);
		
			$this->display('answer_1.html');
	}
	public function answer_2(){
		//已采纳的答案 ******************************************
			$allanswer = "SELECT *FROM hd_answer WHERE accept=1";
			$allanswer = M('wenda')->query($allanswer);
			// var_dump($allask);
			$this->assign('allanswer',$allanswer);
		
			$this->display('answer_1.html');
	}
	
	//删除回答方法
	public function del(){
		$anid = htmlspecialchars($_GET['anid']);
		$delsql = "DELETE FROM hd_answer WHERE anid={$anid}";

		$uid =M('wenda')->exe($delsql);

			//判断
			if($uid>0){
			$this->error('删除成功');

			}else{
				$this->error('删除失败');
			}
		// delete from stu_back where sid=12;
	}



}